package com.test;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import org.junit.Test;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;

public class Equipment {
    @Test
    public void t3() throws FileNotFoundException {
        //1.准备数据
        List<Equipment> list=new ArrayList<>();

        //2.调用方法 写出数据  生成Excel文件
        EasyExcel.write(new FileOutputStream("t2.xlsx"),Equipment.class).sheet("自动生成").doWrite(list);

    }

    @Test
    public void t2() throws FileNotFoundException {
        //1.读取Excel文件
        List<Equipment> list=EasyExcel.read(new FileInputStream("equipment.xlsx"),Equipment.class, new ReadListener() {
            @Override
            public void invoke(Object o, AnalysisContext analysisContext) {
            }
            @Override
            public void doAfterAllAnalysed(AnalysisContext analysisContext) {}
        }).sheet().doReadSync();
        System.err.println("读取的结果："+list);
    }
}
